<?php
/**
 * Author: Keter
 * Date: 2016/8/1
 */
require_once(__DIR__ . '/common.php');

if ($_GET['debug'] === 'doo') {


} else {
    if (php_sapi_name() != 'cli') {
        Application::printError('Invalid PHP run mode.');
    }

    $args = isset($_SERVER['argv'][1]) ? $_SERVER['argv'][1] : '';
    $_GET = formatRequestArgs(explode('/', $args));
}


/**
 * 将命令参数格式化为$_REQUEST
 * @param $args
 * @return array
 */
function formatRequestArgs($args)
{
    $data = array_chunk($args, 2);
    $params = array();

    foreach ($data as $row) {
        $params[$row[0]] = $row[1];
    }

    return $params;
}

Application::run('scripts');

